package com.sky.mapper;

import com.sky.entity.OrderDetail;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface OrderDetailMapper {
    /**
     * 添加订单详情表
     * @param orderDetail
     */
    @Options(keyProperty = "id",useGeneratedKeys = true)
    @Insert("insert into sky_take_out.order_detail values (null,#{name},#{image},#{orderId},#{dishId},#{setmealId},#{dishFlavor},#{number},#{amount})")
    void add(OrderDetail orderDetail);

    /**
     * 根据订单id查询订单详情表
     * @param orderId
     * @return
     */
    @Select("select * from sky_take_out.order_detail where order_id=#{orderId}")
    List<OrderDetail> findByOrderId(Long orderId);
}
